<?
    include "./common.php";
    // echo json_encode($_POST);
    $pidArr = explode(",",$_POST['goodsId']);
    $uid = $_POST['uid'] ;
    $numArr = explode(",",$_POST['goodsNum']) ;
    $now =Time();
    $newArr = [] ;
    foreach( $pidArr as $key=>$value){
        $sql = "INSERT INTO carts (`uid`,pid,num,shoptime) VALUES ({$uid},{$value},{$numArr[$key]},{$now})";
        $res = mysqli_query($link,$sql);
        $arr = [] ;
        $arr['res'] = $res ;
        $newArr[] = $arr ;
    }
    echo json_encode($newArr);
?>